.text
.section .rodata
.align 8
.LC0:
    .string "Level %d: n location %p\n"

.text
.globl main
.type main, @function
main:
    pushq %rbp
    movq	%rsp, %rbp
    movl $1, %edi
    call up_and_down

    movl $0, %eax
    popq %rbp
    ret

.globl up_and_down
.type up_and_down, @function
up_and_down:
    pushq %rbp
    movq %rsp, %rbp
    // 我猜想此地rsp是减了16，不过我这里来搞个不减的，那样是不是地址每次减少16字节？
    // 不行地，我刚刚写了一行命令就感觉不行，因为要调用函数，必须把参数放在局部变量，即堆栈里，所以还是需要subq
    subq $16, %rsp
    // -4(%rbp) 存放参数n
    movl %edi, -4(%rbp)

    movl -4(%rbp), %esi
    leaq -4(%rbp), %rdx
    movq $.LC0, %rdi
    movl $0, %eax
    call printf

    movl -4(%rbp), %eax
    movl $3, %edx
    cmpl %edx, %eax
    jg .L2
.L1:
    movl -4(%rbp), %eax
    incl %eax
    movl %eax, %edi
    call up_and_down
.L2:
    movl -4(%rbp), %esi
    leaq -4(%rbp), %rdx
    movq $.LC0, %rdi
    movl $0, %eax
    call printf

    movq %rbp, %rsp
    popq %rbp
    ret